package com.example.toast;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

public class ToastActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toast);
    }
    public void click(View view){
        switch(view.getId()){
            case R.id.btn:
                Toast.makeText(ToastActivity.this, "按钮被点击啦", Toast.LENGTH_SHORT).show();
                break;
            case R.id.btn1:
                Toast toast=Toast.makeText(ToastActivity.this, "请检查网络", Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER,0,0);
                toast.show();
        }
    }
}
